/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.deployment.manager.search;

import br.com.deployment.daoImpl.IssuesDAOImpl;
import br.com.deployment.daoImpl.OptionsDAOImpl;
import br.com.deployment.entities.Issues;
import br.com.deployment.entities.Options;
import br.com.deployment.utils.Msg;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author ely
 */
@ManagedBean
@SessionScoped
public class ManagerEditIssues {
    
    // Objetos
    private Issues issues;
    
    private Issues editIssues;
    
    private Issues removeIssues;
    
    @EJB
    IssuesDAOImpl  issuesService;
    @EJB
    OptionsDAOImpl optionsService;
    
    private Options options;
    
    public ManagerEditIssues(){
        this.options = new Options();        
    }
    
    public void update(){
        issuesService.update(editIssues);
        Msg.messagemInfo("Atualizado com Sucesso ");
    } 
     
    public void addOption(){
        this.editIssues.getOptions().add(options);
        this.options = new Options();
    }
    
    public void removeOption(Options options){
        this.editIssues.getOptions().remove(options);
    }
    
     public void redirect(String string, Issues i) {
        try {
            FacesContext context = FacesContext.getCurrentInstance();
            this.editIssues = i;
            context.getExternalContext().redirect(string);
        } catch (IOException ex) {
            Logger.getLogger(ManagerEditExecutor.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    public void editIssues(Issues i){
       issues = i;
       if(issues.getTypeIssues().equals(issues.getTypeIssues().CHOICEMULTIPLE)){
           
       }
    }

    public Issues getEditIssues() {
        return editIssues;
    }

    public void setEditIssues(Issues editIssues) {
        this.editIssues = editIssues;
    }

    public Options getOptions() {
        return options;
    }

    public void setOptions(Options options) {
        this.options = options;
    }

    public Issues getRemoveIssues() {
        return removeIssues;
    }

    public void setRemoveIssues(Issues removeIssues) {
        this.removeIssues = removeIssues;
    }
}
